/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package foxmob.mlts.viewcontroller.setter;

import foxmob.mlts.controller.setter.SetterFormController;
import javax.swing.JPanel;
import javax.swing.JTree;

/**
 *
 * @author Lunayo
 */
public class SetterForm extends javax.swing.JFrame  {

    /**
     * Creates new form SetterForm
     */
    
    private SetterFormController setterFormController;
    
    public SetterForm() {
        initComponents();
        setterFormController = new SetterFormController();
        setterFormController.setDelegate(this);
    }
    
    public SetterFormController getSetterFormController() {
        return this.setterFormController;
    }
    
    public JTree getRecordTree() {
        return this.recordTree;
    }
    
    public JPanel getDetailPanel() {
        return this.detailPanel;
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        setterPanel = new javax.swing.JPanel();
        jScrollPane1 = new javax.swing.JScrollPane();
        recordTree = new javax.swing.JTree();
        arrowUpButton = new javax.swing.JButton();
        arrowDownButton = new javax.swing.JButton();
        detailPanel = new javax.swing.JPanel();
        setterMenuBar = new javax.swing.JMenuBar();
        fileMenu = new javax.swing.JMenu();
        newMenuItem = new javax.swing.JMenuItem();
        openMenuItem = new javax.swing.JMenuItem();
        menuEdit = new javax.swing.JMenu();
        defaultTestMenuItem = new javax.swing.JMenuItem();
        menuView = new javax.swing.JMenu();
        menuItemSetter = new javax.swing.JMenuItem();
        menuItemPreview = new javax.swing.JMenuItem();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

        setterPanel.setBorder(javax.swing.BorderFactory.createTitledBorder("MELT Record"));

        javax.swing.tree.DefaultMutableTreeNode treeNode1 = new javax.swing.tree.DefaultMutableTreeNode("root");
        recordTree.setModel(new javax.swing.tree.DefaultTreeModel(treeNode1));
        recordTree.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                recordTreeMouseClicked(evt);
            }
        });
        recordTree.addTreeSelectionListener(new javax.swing.event.TreeSelectionListener() {
            public void valueChanged(javax.swing.event.TreeSelectionEvent evt) {
                recordTreenodeSelection(evt);
            }
        });
        jScrollPane1.setViewportView(recordTree);

        arrowUpButton.setText("▲");
        arrowUpButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                arrowUpButtonActionPerformed(evt);
            }
        });

        arrowDownButton.setText("▼");
        arrowDownButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                arrowDownButtonActionPerformed(evt);
            }
        });

        org.jdesktop.layout.GroupLayout setterPanelLayout = new org.jdesktop.layout.GroupLayout(setterPanel);
        setterPanel.setLayout(setterPanelLayout);
        setterPanelLayout.setHorizontalGroup(
            setterPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(setterPanelLayout.createSequentialGroup()
                .add(6, 6, 6)
                .add(jScrollPane1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 448, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .add(1, 1, 1)
                .add(setterPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING, false)
                    .add(arrowDownButton, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 25, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                    .add(arrowUpButton, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE))
                .addContainerGap(org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        setterPanelLayout.setVerticalGroup(
            setterPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(setterPanelLayout.createSequentialGroup()
                .add(arrowUpButton, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 25, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .add(1, 1, 1)
                .add(arrowDownButton, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 25, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
            .add(jScrollPane1)
        );

        detailPanel.setLayout(new java.awt.BorderLayout());

        fileMenu.setText("File");

        newMenuItem.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_N, java.awt.event.InputEvent.CTRL_MASK));
        newMenuItem.setText("New record...");
        newMenuItem.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                newMenuItemActionPerformed(evt);
            }
        });
        fileMenu.add(newMenuItem);

        openMenuItem.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_O, java.awt.event.InputEvent.CTRL_MASK));
        openMenuItem.setText("Open record...");
        openMenuItem.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                openMenuItemActionPerformed(evt);
            }
        });
        fileMenu.add(openMenuItem);

        setterMenuBar.add(fileMenu);

        menuEdit.setText("Edit");

        defaultTestMenuItem.setText("Set student test");
        defaultTestMenuItem.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                defaultTestMenuItemActionPerformed(evt);
            }
        });
        menuEdit.add(defaultTestMenuItem);

        setterMenuBar.add(menuEdit);

        menuView.setText("View");

        menuItemSetter.setText("Setter");
        menuView.add(menuItemSetter);

        menuItemPreview.setText("Preview");
        menuItemPreview.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                menuItemPreviewActionPerformed(evt);
            }
        });
        menuView.add(menuItemPreview);

        setterMenuBar.add(menuView);

        setJMenuBar(setterMenuBar);

        org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(layout.createSequentialGroup()
                .addContainerGap()
                .add(setterPanel, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(detailPanel, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(11, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(org.jdesktop.layout.GroupLayout.TRAILING, layout.createSequentialGroup()
                .addContainerGap()
                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)
                    .add(detailPanel, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .add(setterPanel, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addContainerGap())
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void recordTreenodeSelection(javax.swing.event.TreeSelectionEvent evt) {//GEN-FIRST:event_recordTreenodeSelection
        // TODO add your handling code here:
        setterFormController.recordTreeNodeSelection();
    }//GEN-LAST:event_recordTreenodeSelection

    private void menuItemPreviewActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_menuItemPreviewActionPerformed
        // TODO add your handling code here:
        setterFormController.menuItemPreviewDidTap();
    }//GEN-LAST:event_menuItemPreviewActionPerformed

    private void openMenuItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_openMenuItemActionPerformed
        // TODO add your handling code here:
        setterFormController.openMenuItemDidTap();
    }//GEN-LAST:event_openMenuItemActionPerformed

    private void newMenuItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_newMenuItemActionPerformed
        // TODO add your handling code here:
        setterFormController.newMenuItemDidTap();
    }//GEN-LAST:event_newMenuItemActionPerformed

    private void arrowUpButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_arrowUpButtonActionPerformed
        // TODO add your handling code here:
        setterFormController.arrowButtonUpDidTap();
    }//GEN-LAST:event_arrowUpButtonActionPerformed

    private void arrowDownButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_arrowDownButtonActionPerformed
        // TODO add your handling code here:
        setterFormController.arrowButtonDownDidTap();
    }//GEN-LAST:event_arrowDownButtonActionPerformed

    private void defaultTestMenuItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_defaultTestMenuItemActionPerformed
        // TODO add your handling code here:
        setterFormController.defaultTestMenuDidTap();
    }//GEN-LAST:event_defaultTestMenuItemActionPerformed

    private void recordTreeMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_recordTreeMouseClicked
        // TODO add your handling code here:
        setterFormController.recordTreeMouseDidClick();
    }//GEN-LAST:event_recordTreeMouseClicked

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /* Set the Nimbus look and feel */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(SetterForm.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(SetterForm.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(SetterForm.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(SetterForm.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /* Create and display the form */
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new SetterForm().setVisible(true);
            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton arrowDownButton;
    private javax.swing.JButton arrowUpButton;
    private javax.swing.JMenuItem defaultTestMenuItem;
    private javax.swing.JPanel detailPanel;
    private javax.swing.JMenu fileMenu;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JMenu menuEdit;
    private javax.swing.JMenuItem menuItemPreview;
    private javax.swing.JMenuItem menuItemSetter;
    private javax.swing.JMenu menuView;
    private javax.swing.JMenuItem newMenuItem;
    private javax.swing.JMenuItem openMenuItem;
    private javax.swing.JTree recordTree;
    private javax.swing.JMenuBar setterMenuBar;
    private javax.swing.JPanel setterPanel;
    // End of variables declaration//GEN-END:variables

    
}
